home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Pascal / Libraries / Tools Plus 2.1 Pascal ƒ / Tools Plus 2.1 for Pascal / ToolsPlus.p < prev   
Encoding:
Text File  |  1993-10-24  |  35.4 KB  |  728 lines  |  [TEXT/PJMM]

  1. {    Tools Plus (Version 2.1) Pascal interface                                                                        }
  2. {    Copyright (C) 1989-1993 Water’s Edge Software                                                                }
  3.  
  4. {    This unit is the interface between Pascal applications and Tools Plus.  It must be used by any program or unit    }
  5. {    that makes reference to any part of Tools Plus.                                                                    }
  6. {                                                                                                                    }
  7. {    All TYPEs, VARiables, and CONSTants required by Tools Plus are included.                                        }
  8. {                                                                                                                    }
  9. {    The entire "implementation" is external, thereby requiring the use of both Tools Plus library files:                    }
  10. {    "ToolsPlus.Lib1" and "ToolsPlus.Lib2"                                                                            }
  11.  
  12.  
  13. unit ToolsPlus;
  14.  
  15.  
  16. interface
  17.     const
  18.         UseColor = true;                                                {INITIALIZATION:    Use color if available        }
  19.         IgnoreColor = false;                                                {                    Don't use color                }
  20.         doNothing = 0;                                                    {POLLING:    no event                            }
  21.         doChgWindow = 1;                                                {            user clicked in an inactive window    }
  22.         doRefresh = 2;                                                    {            a window has to be refreshed        }
  23.         doGoAway = 3;                                                    {            the close box was clicked            }
  24.         doButton = 4;                                                    {            button was clicked                    }
  25.         doMenu = 5;                                                    {            menu was selected                    }
  26.         doKeyDown = 6;                                                {            a keyboard key was pressed        }
  27.         doAutoKey = 7;                                                    {            a keyboard key is auto-repeating    }
  28.         doKeyUp = 8;                                                    {            a keyboard key was released        }
  29.         doClickField = 9;                                                {            mouse clicked in inactive field        }
  30.         doScrollBar = 10;                                                {            mouse clicked in a scroll bar        }
  31.         doListBox = 11;                                                    {            some sort of List Box activity        }
  32.         doClick = 12;                                                    {            mouse click/drag                    }
  33.         doClickControl = 101;                                            {            mouse clicked in a custom control    }
  34.         doManualEvent = 102;                                            {            manually processed events            }
  35.         doMoveWindow = 103;                                            {            a window was moved by user        }
  36.         doGrowWindow = 104;                                            {            a window was re-sized by the user    }
  37.         doClickDesk = 105;                                                {            mouse clicked in the desk top        }
  38.         doZoomWindow = 106;                                            {            zoom box was clicked by user        }
  39.         doSuspend = 107;                                                {            appl. suspended (in background)    }
  40.         doResume = 108;                                                {            appl. resumed (now active appl.)    }
  41.         inClick1 = 1;                                                    {CLICK:    mouse single-click completed        }
  42.         inClick2 = 2;                                                    {            mouse double-click completed        }
  43.         inClick3 = 3;                                                    {            mouse triple-click completed        }
  44.         inClick1Drag = -1;                                                {            mouse single-click, still dragging    }
  45.         inClick2Drag = -2;                                                {            mouse double-click, still dragging    }
  46.         inClick3Drag = -3;                                                {            mouse triple-click, still dragging        }
  47.         EnterKey = char($03);                                            {KEYS:        Key characters (ASCII) for common    }
  48.         BackSpaceKey = char($08);                                    {                non apha-numeric keys.        }
  49.         TabKey = char($09);                                            {                In some cases, several keys    }
  50.         ReturnKey = char($0D);                                            {                produce the same ASCII        }
  51.         EscClearKey = char($1B);                                        {  ($1B)            character.  They can be            }
  52.         LeftArrowKey = char($1C);                                        {                differentiated by using the key    }
  53.         RightArrowKey = char($1D);                                    {                code, as indicated below.        }
  54.         UpArrowKey = char($1E);                                        {                Some keys are available only    }
  55.         DownArrowKey = char($1F);                                    {                on an extended keyboard.        }
  56.         HelpKey = char($05);                                            {                                                }
  57.         HomeKey = char($01);                                            {                                                }
  58.         DeleteFwdKey = char($7F);                                        {                                                }
  59.         EndKey = char($04);                                            {                                                }
  60.         PageUpKey = char($0B);                                        {                                                }
  61.         PageDownKey = char($0C);                                        {                                                }
  62.         FKey = char($10);                                                {  ($10)        Function keys F1 to F15            }
  63.         EscKeyCode = $35;                                            {  ($1B)        KEY CODES used to differentiate    }
  64.         ClearKeyCode = $47;                                            {  ($1B)            between keys which produce    }
  65.         F1KeyCode = $7A;                                                {                the same key characters.        }
  66.         F2KeyCode = $78;                                                {                                                }
  67.         F3KeyCode = $63;                                                {                                                }
  68.         F4KeyCode = $76;                                                {                                                }
  69.         F5KeyCode = $60;                                                {                                                }
  70.         F6KeyCode = $61;                                                {                                                }
  71.         F7KeyCode = $62;                                                {                                                }
  72.         F8KeyCode = $64;                                                {                                                }
  73.         F9KeyCode = $65;                                                {                                                }
  74.         F10KeyCode = $6D;                                            {                                                }
  75.         F11KeyCode = $67;                                                {                                                }
  76.         F12KeyCode = $6F;                                                {                                                }
  77.         F13KeyCode = $69;                                                {                                                }
  78.         F14KeyCode = $6B;                                            {                                                }
  79.         F15KeyCode = $71;                                                {                                                }
  80.         AppleChar = char($14);                                            {MENU CHARS:    Apple character                }
  81.         CheckChar = char($12);                                        {                Check Mark character            }
  82.         DiamondChar = char($13);                                        {                Diamond character                }
  83.         DotChar = char($A5);                                            {                Dot (or bullet) character            }
  84.         NoChar = char($00);                                            {                no character                    }
  85.         arrowCursor = 0;                                                {CURSORS:    "arrow" cursor                    }
  86.         GoAway = true;                                                    {WINDOWS:    no "close box"                    }
  87.         NoGoAway = false;                                                {                window has a "close box"        }
  88.         Modal = true;                                                    {                window is modal                }
  89.         NotModal = false;                                                {                window is modeless                }
  90.         ZoomBox = 8;                                                    {                window has a "zoom box"        }
  91.         DefaultButton = 4;                                                {BUTTONS:        “default” for the window            }
  92.         selected = true;                                                    {                button is selected (i.e. checked)}
  93.         notSelected = false;                                            {                button is not selected            }
  94.                                                                     {BUTTONS, MENUS, SCROLL BARS & ICONS:    }
  95.         enabled = true;                                                    {                object is enabled                }
  96.         disabled = false;                                                {                object is disabled                }
  97.         teBoxNoCR = 0;                                                {EDIT FIELDS:    box around field, no CR allowed    }
  98.         teBoxCR = 1;                                                    {                box around field, CR allowed    }
  99.         teNoBoxNoCR = 2;                                                {                no box, no CR allowed            }
  100.         teNoBoxCR = 3;                                                {                no box, CR allowed                }
  101.         teSelectAll = 0;                                                    {EDIT FIELD SELECTION:    all of text            }
  102.         teSelectStart = 1;                                                {                            beginning of text    }
  103.         teSelectEnd = 2;                                                {                            end of text            }
  104.         teReplace = true;                                                {PASTE INTO FIELD:    replace field contents    }
  105.         teInsert = false;                                                {                        insert text into field        }
  106.         OkAltBut = 1;                                                    {ALERTS:    OK                (Buttons refs)        }
  107.         CanAltBut = 2;                                                    {            Cancel                                }
  108.         YesAltBut = 3;                                                    {            Yes                                }
  109.         NoAltBut = 4;                                                    {            No                                    }
  110.         ContAltBut = 5;                                                    {            Continue                            }
  111.         SkipAltBut = 6;                                                    {            Skip                                }
  112.         QuitAltBut = 7;                                                    {            Quit                                }
  113.         NoButtonAlert = 0;                                                {            No buttons        (Alert Defs)            }
  114.         OkAlert = 11100;                                                {            OK (default)                        }
  115.         CanAlert = 11200;                                                {            Cancel (default)                    }
  116.         OkCanAlert = 22210;                                            {            OK (default) + Cancel                }
  117.         CanOkAlert = 21210;                                            {            OK + Cancel (default)                }
  118.         YesNoAlert = 22430;                                            {            Yes (default) + No                    }
  119.         NoYesAlert = 21430;                                            {            Yes + No (default)                     }
  120.         YesNoCanAlert = 33243;                                        {            Yes (default) + No + Cancel            }
  121.         NoYesCanAlert = 32243;                                        {            Yes + No (default) + Cancel            }
  122.         NoIcon = -32768;                                                {ICONS:    No icon used                        }
  123.         on = true;                                                        {MISCELLANEOUS:                            }
  124.         off = false;                                                        {                                                }
  125.         ZoomAcross = 0;                                                {ZOOM LINES:    transitional                        }
  126.         ZoomIn = -1;                                                    {                zoom inward (further away)        }
  127.         ZoomOut = 1;                                                    {                zoom outward (nearer)            }
  128.         none = 0;                                                        {used primarily for polling                        }
  129.  
  130.  
  131.  
  132.  
  133.     type
  134.         TP_MoreMasters = 0..128;                                        {Legal range of MoreMasters initialization cycles}
  135.         TP_Mnums = 1..15;                                                {Legal range of Menu numbers                    }
  136.         TP_Mnums0 = 0..15;                                            {Legal range of Menu numbers (& 0= all menus)    }
  137.         TP_MInums = 1..255;                                            {Legal range of Menu item No.s                    }
  138.         TP_MInums0 = 0..255;                                            {Legal range of Menu item No.s (& 0= all items)    }
  139.         TP_WNums = 1..50;                                            {Legal range of Window numbers                }
  140.         TP_BNums = 1..255;                                            {Legal range of Button numbers                    }
  141.         TP_SNums = 1..255;                                            {Legal range of Scroll Bar numbers                }
  142.         TP_TeNums = 1..255;                                            {Legal range of Text Editing Field numbers        }
  143.         TP_LNums = 1..255;                                            {Legal range of List Box numbers                }
  144.         TP_LnNums = 1..32767;                                        {Legal range of List Box line numbers            }
  145.         TP_CtNums = 1..255;                                            {Legal range of Cursor Table numbers            }
  146.         TP_CtNums0 = 0..255;                                            {Legal range of Cursor Table No. (& 0=no table)    }
  147.         TP_CzNums = 1..255;                                            {Legal range of Cursor Zones in a cursor table    }
  148.         TP_AltBoxBNums = 1..9;                                        {Legal range of Alert Box button numbers        }
  149.  
  150.  
  151.     { -   -   -   -   -   -   -   -   -   -   These record "types" are used for information transfer between   -   -   -   -   -   -   -   -   -   -   -    }
  152.     {                                     your application and Tools Plus libraries.                                    }
  153.  
  154.     {= Polling record's "event modifiers" info}
  155.         TPModifiersRec = packed record                                {This variable record contains an event's        }
  156.                 case integer of                                            {    "modifiers" in 2 formats…                    }
  157.                     0: (                                                        {    • Macintosh Event:                            }
  158.                             Num: integer                                            {        integer (bit operations required)            }
  159.                     );                                                            {                                                }
  160.                     1: (                                                        {    • Modifier integer parsed into components:    }
  161.                             bit15, bit14, bit13: boolean;                            {        (reserved bits)                            }
  162.                             ControlKey: boolean;                                    {        Control key was down at event (=1)        }
  163.                             OptionKey: boolean;                                    {        Option key was down at event (=1)        }
  164.                             CapsLock: boolean;                                    {        Caps Lock was down at event (=1)        }
  165.                             ShiftKey: boolean;                                    {        Shift key was down at event (=1)        }
  166.                             CmdKey: boolean;                                    {        Command key was down at event (=1)    }
  167.                             MouseUp: boolean;                                    {        Mouse button was UP at event (=1)        }
  168.                             bit6, bit5, bit4, bit3, bit2, bit1, bit0: boolean            {        (reserved bits)                            }
  169.                     );                                                            {                                                }
  170.             end;
  171.     {= Polling record's "button" info}
  172.         TPPollButtonRec = record
  173.                 Num: integer;                                                {Button number                                    }
  174.                 DoubleClick: boolean                                        {Did a double-click occur?                        }
  175.             end;
  176.     {= Polling record's "scroll bar" info}
  177.         TPPollScrollBarRec = record
  178.                 Num: integer;                                                {Scroll bar number                                }
  179.                 Part: integer                                                {Scroll bar's part                                }
  180.             end;
  181.     {= Polling record's "list box" info}
  182.         TPPollListBoxRec = record
  183.                 Num: integer;                                                {List box number                                }
  184.                 DoubleClick: boolean                                        {Did a double-click occur?                        }
  185.             end;
  186.     {= Polling record's "menu" info}
  187.         TPPollMenuRec = record
  188.                 Num: integer;                                                {Menu number                                    }
  189.                 Item: integer                                                {Menu item number                                }
  190.             end;
  191.     {= Polling record's "key-stroke" info}
  192.         TPPollKeyRec = packed record
  193.                 Code: integer;                                                {Logical key number of the typed key            }
  194.                 Chr: char;                                                    {ASCII character generated by typed key        }
  195.                 Unused: byte                                                { (reserved byte)                                }
  196.             end;
  197.     {= Polling record's "mouse location and time" info for mouse-down and mouse-up events}
  198.         TPPollMousePointRec = record
  199.                 Where: point;                                                {Event location in local co-ordinates            }
  200.                 When: longint;                                                {Event time in clock ticks from boot (1/60 sec)    }
  201.                 Modifiers: TPModifiersRec                                    {Event modifiers                                }
  202.             end;
  203.     {= Polling record's "mouse click/drag" info}
  204.         TPPollMouseRec = record
  205.                 What: integer;                                                {What type of mouse event? (click or drag)        }
  206.                 Down: array[1..3] of TPPollMousePointRec;                {Where & when did the mouse-down occur        }
  207.                 Up: array[1..3] of TPPollMousePointRec;                    {Where & when did the mouse-up occur            }
  208.                 Where: point                                                {Current mouse location in local co-ordinates    }
  209.             end;
  210.     {= POLLING record for Tools Plus}
  211.         TPPollPointer = ^TPPollRecord;                                    {Pointer to a Polling record                        }
  212.  
  213.         TPPollRecord = record                                        {Tools Plus Polling record…                        }
  214.                 What: integer;                                                {What type of event has occurred?                }
  215.                 Window: integer;                                            {Window number of the event                    }
  216.                 Button: TPPollButtonRec;                                    {Button number/double-click status                }
  217.                 ScrollBar: TPPollScrollBarRec;                                {Scroll bar number/scroll bar part                }
  218.                 Field: integer;                                                {Field number of event                            }
  219.                 ListBox: TPPollListBoxRec;                                {List box number/double-click status            }
  220.                 Menu: TPPollMenuRec;                                        {Menu number/menu item of an event            }
  221.                 Key: TPPollKeyRec;                                        {Logical key number & character of typed key    }
  222.                 Mouse: TPPollMouseRec;                                    {Click/drag info: [1..3] where & when            }
  223.                 Modifiers: TPModifiersRec;                                    {Modifier flags                                    }
  224.                 Event: EventRecord                                        {Macintosh Toolbox Event (raw)                    }
  225.             end;
  226.  
  227.     {= WINDOW status information}
  228.         TPWindowStatus = record
  229.                 Open: boolean;                                                {Is the window open?                            }
  230.                 Active: boolean;                                            {Is this the active window?                        }
  231.                 Current: boolean;                                            {Is this the current window?                        }
  232.                 Front: boolean;                                                {Is this the front most Tools Plus window?        }
  233.                                                                     {    (which may be inactive due to an active        }
  234.                                                                     {    dialog or desk accessory under System 6)    }
  235.                 Size: point;                                                    {Size in pixels (.h=horizontal, .v=vertical)        }
  236.                 Where: point                                                {Location of top-left corner in global co-ordinates}
  237.             end;
  238.  
  239.     {= Color Pen information}
  240.         ColorPenState = record                                        {Color equivalent for a 'PenState' record.  This    }
  241.                 PenState: PenState;                                        {    record also stores additional values for the    }
  242.                 ForegroundColor: RGBColor;                                {    window's foreground and background        }
  243.                 BackgroundColor: RGBColor                                {    colors.                                        }
  244.             end;
  245.  
  246.  
  247.  
  248.  
  249. {==================================== I N I T I A L I Z A T I O N ====================================    }
  250. {Initialize Tools Plus}
  251.     function InitToolsPlus (MoreHandles: TP_MoreMasters;            {Number of MoreMasters initializing cycles        }
  252.                                     MaxWindows: TP_WNums;                        {Maximum number of windows required            }
  253.                                     UseColorFlag: boolean                            {Should Color QuickDraw be used if available?    }
  254.                                     ): Boolean;                                        {Was initialization successful?                    }
  255.  
  256.  
  257. {======================================= W I N D O W S ========================================    }
  258. {Open a window and make it active}
  259.     procedure WindowOpen (Window: TP_WNums;                    {Window number                                }
  260.                                     left, top, right, bottom: Integer;                    {Window's co-ordinates (global)                    }
  261.                                     Title: string;                                        {Window's title (if applicable)                    }
  262.                                     procID: Integer;                                    {Window definition ID                            }
  263.                                     goAwayFlag, modalFlag: Boolean);                {Include Close Box?  Is window modal?            }
  264.  
  265. {Open a window and make it active (co-ordinates specified as a 'rect') }
  266.     procedure WindowOpenRect (Window: TP_WNums;                {Window number                                }
  267.                                     Bounds: rect;                                        {Window's co-ordinates (global)                    }
  268.                                     Title: string;                                        {Window's title (if applicable)                    }
  269.                                     procID: Integer;                                    {Window definition ID                            }
  270.                                     goAwayFlag, modalFlag: Boolean);                {Include Close Box?  Is window modal?            }
  271.  
  272. {Close a window}
  273.     procedure WindowClose (Window: TP_WNums);                {Window number                                }
  274.  
  275. {Make a specified window the "active" and "current" window}
  276.     procedure ActivateWindow (Window: TP_WNums);                {Window number                                }
  277.  
  278. {Set a window's title}
  279.     procedure WindowTitle (Window: TP_WNums;                    {Window number                                }
  280.                                     Title: string);                                    {Window's title (if applicable)                    }
  281.  
  282. {Set the current window's "dragging" boundary for the cursor}
  283.     procedure SetCursDragBounds (left, top, right, bottom: Integer);{Cursor's "window dragging" boundary (global)    }
  284.  
  285. {Set the current window's "growing" limits (i.e. maximum/minimum size) }
  286.     procedure SetWindowSizeLimits (minHoriz, minVert, maxHoriz, MaxVert: Integer);{Window's size limits in pixels}
  287.  
  288. {Set the current window's standard co-ordinates and user co-ordinates for "zooming"}
  289.     procedure SetWindowZoom (userRect, stdRect: rect);            {User & standard co-ordinates (global)            }
  290.  
  291. {Get the current window's user co-ordinates & standard co-ordinates for "zooming"}
  292.     procedure GetWindowZoom (var userRect, stdRect: Rect);        {User & standard co-ordinates (global)            }
  293.  
  294. {Make a specified window "current", but do not activate it}
  295.     procedure CurrentWindow (Window: TP_WNums);                {Window number                                }
  296.  
  297. {Make the "active" window "current"}
  298.     procedure CurrentWindowReset;
  299.  
  300. {Get a window's status}
  301.     procedure WindowStatus (Window: TP_WNums;                {Window number                                }
  302.                                     var Status: TPWindowStatus);                    {Window's status record                        }
  303.  
  304. {Get the active window number}
  305.     function ActiveWindowNumber: integer;                            {Window number of active window                }
  306.  
  307. {Get the current window number}
  308.     function CurrentWindowNumber: integer;                        {Window number of current window                }
  309.  
  310. {Get the front most window number}
  311.     function FirstWindowNumber: integer;                            {Window number of front most window            }
  312.  
  313. {Get a window's "window pointer" }
  314.     function WindowPointer (Window: TP_WNums                    {Window number                                }
  315.                                     ): WindowPtr;                                        {Window's pointer                                }
  316.  
  317.  
  318. {======================================== B U T T O N S ========================================    }
  319. {All button operations pertain to the "current" window.}
  320.  
  321. {Create a new button}
  322.     procedure NewButton (Button: TP_BNums;                        {Button number                                    }
  323.                                     left, top, right, bottom: Integer;                    {Button's co-ordinates (local)                    }
  324.                                     Title: string;                                        {Button's title                                    }
  325.                                     procID: Integer;                                    {Button's definition ID                            }
  326.                                     EnabledFlag, SelectedFlag: boolean);                {Enable the button?  Select the button?            }
  327.  
  328. {Create a new button  (co-ordinates specified as a 'rect') }
  329.     procedure NewButtonRect (Button: TP_BNums;                {Button number                                    }
  330.                                     Bounds: rect;                                        {Button's co-ordinates (local)                    }
  331.                                     Title: string;                                        {Button's title                                    }
  332.                                     procID: Integer;                                    {Button's definition ID                            }
  333.                                     EnabledFlag, SelectedFlag: boolean);                {Enable the button?  Select the button?            }
  334.  
  335. {Delete a button}
  336.     procedure DeleteButton (Button: TP_BNums);                    {Button number                                    }
  337.  
  338. {Enable/disable a button}
  339.     procedure EnableButton (Button: TP_BNums;                    {Button number                                    }
  340.                                     EnabledFlag: boolean);                            {Enable the button?                                }
  341.  
  342. {Select/deselect a button}
  343.     procedure SelectButton (Button: TP_BNums;                    {Button number                                    }
  344.                                     SelectedFlag: boolean);                            {Select the button?                                }
  345.  
  346. {Determine if a button is enabled}
  347.     function ButtonIsEnabled (Button: TP_BNums                    {Button number                                    }
  348.                                     ): boolean;                                        {Is the button enabled?                            }
  349.  
  350. {Determine if a button is selected}
  351.     function ButtonIsSelected (Button: TP_BNums                    {Button number                                    }
  352.                                     ): boolean;                                        {Is the button selected?                        }
  353.  
  354. {Set a button's title}
  355.     procedure ButtonTitle (Button: TP_BNums;                        {Button number                                    }
  356.                                     Title: string);                                    {Button's title                                    }
  357.  
  358. {Make a button the window's default button}
  359.     procedure SetDefaultButton (Button: TP_BNums);                {Button number                                    }
  360.  
  361. {Remove the "default button status" from the window's default button}
  362.     procedure NoDefaultButton;
  363.  
  364. {"Flash" a push button as though it were pressed by the user}
  365.     procedure FlashButton (Button: TP_BNums);                    {Button number                                    }
  366.  
  367.  
  368. {===================================== S C R O L L   B A R S ======================================    }
  369. {All scroll bar operations pertain to the "current" window.}
  370.  
  371. {Create a new scroll bar}
  372.     procedure NewScrollBar (ScrollBar: TP_SNums;                {Scroll bar number                                }
  373.                                     left, top, right, bottom: Integer;                    {Scroll bar's co-ordinates (local)                }
  374.                                     EnabledFlag: boolean;                            {Enable the scroll bar?                            }
  375.                                     minimum, value, maximum: integer);                {Minimum, current, and maximum value            }
  376.  
  377. {Create a new scroll bar (co-ordinates specified as a 'rect') }
  378.     procedure NewScrollBarRect (ScrollBar: TP_SNums;            {Scroll bar number                                }
  379.                                     Bounds: rect;                                        {Scroll bar's co-ordinates (local)                }
  380.                                     EnabledFlag: boolean;                            {Enable the scroll bar?                            }
  381.                                     minimum, value, maximum: integer);                {Minimum, current, and maximum value            }
  382.  
  383. {Delete a scroll bar}
  384.     procedure DeleteScrollBar (ScrollBar: TP_SNums);                {Scroll bar number                                }
  385.  
  386. {Enable/disable a scroll bar}
  387.     procedure EnableScrollBar (ScrollBar: TP_SNums;                {Scroll bar number                                }
  388.                                     EnabledFlag: boolean);                            {Enable the scroll bar?                            }
  389.  
  390. {Get a scroll bar's minimum setting}
  391.     function GetScrollBarMin (ScrollBar: TP_SNums                {Scroll bar number                                }
  392.                                     ): integer;                                            {Scroll bar's minimum setting                    }
  393.  
  394. {Set a scroll bar's minimum setting}
  395.     procedure SetScrollBarMin (ScrollBar: TP_SNums;                {Scroll bar number                                }
  396.                                     minimum: integer);                                {Scroll bar's minimum setting                    }
  397.  
  398. {Get a scroll bar's maximum setting}
  399.     function GetScrollBarMax (ScrollBar: TP_SNums                {Scroll bar number                                }
  400.                                     ): integer;                                            {Scroll bar's maximum setting                    }
  401.  
  402. {Set a scroll bar's maximum setting}
  403.     procedure SetScrollBarMax (ScrollBar: TP_SNums;                {Scroll bar number                                }
  404.                                     maximum: integer);                                {Scroll bar's maximum setting                    }
  405.  
  406. {Get a scroll bar's current value}
  407.     function GetScrollBarVal (ScrollBar: TP_SNums                {Scroll bar number                                }
  408.                                     ): integer;                                            {Scroll bar's current value                        }
  409.  
  410. {Set a scroll bar's current value}
  411.     procedure SetScrollBarVal (ScrollBar: TP_SNums;                {Scroll bar number                                }
  412.                                     value: integer);                                    {Scroll bar's current value                        }
  413.  
  414.  
  415. {==================================== E D I T I N G   F I E L D S ====================================    }
  416. {All scroll bar operations pertain to the "current" window.}
  417.  
  418. {Create a new field}
  419.     procedure NewField (Field: TP_TeNums;                        {Field number                                    }
  420.                                     left, top, right, bottom: Integer;                    {Field's viewing area co-ordinates (local)        }
  421.                                     hStr: Handle;                                        {Handle to edit field's text                        }
  422.                                     teType: integer;                                    {Type: box around field and/or CR allowed?        }
  423.                                     Just: integer);                                    {Justification: left, center, right                    }
  424.  
  425. {Create a new field (co-ordinates specified as a 'rect') }
  426.     procedure NewFieldRect (Field: TP_TeNums;                    {Field number                                    }
  427.                                     Bounds: rect;                                        {Field's viewing area co-ordinates (local)        }
  428.                                     hStr: Handle;                                        {Handle to edit field's text                        }
  429.                                     teType: integer;                                    {Type: box around field and/or CR allowed?        }
  430.                                     Just: integer);                                    {Justification: left, center, right                    }
  431.  
  432. {Delete a field}
  433.     procedure DeleteField (Field: TP_TeNums);                        {Field number                                    }
  434.  
  435. {Activate a  field}
  436.     procedure ActivateField (Field: TP_TeNums;                    {Field number                                    }
  437.                                     Selection: integer);                                {Text selection: all, start, end                    }
  438.  
  439. {Deactivate the active field}
  440.     procedure DeactivateField;
  441.  
  442. {Process a mouse click in an inactive field.  The click has been detected by the PollSystem procedure.}
  443.     procedure ClickInField;
  444.  
  445. {Get the active field's edited text}
  446.     procedure GetFieldString (var EditString: str255);                {Field's edited text                                }
  447.  
  448. {Save the active field's edited text in the field's string}
  449.     procedure SaveFieldString;
  450.  
  451. {Determine the active field number}
  452.     function ActiveFieldNumber: integer;                            {Active field number                            }
  453.  
  454. {Turn string length limiting on/off for each new field created starting now}
  455.     procedure FieldLengthLimit (Limits: boolean);                    {Should newly created fields be length-limited?    }
  456.  
  457. {Offset a field}
  458.     procedure OffsetField (Field: TP_TeNums;                        {Field number                                    }
  459.                                     dh, dv: integer);                                    {Number of pixels to be offset (horiz/vert)        }
  460.  
  461. {Paste text into a field}
  462.     procedure PasteIntoField (Field: TP_TeNums;                    {Field number                                    }
  463.                                     Text: string;                                        {Text which is to be pasted                        }
  464.                                     Replace: boolean);                                {Replace all existing text in field?                }
  465.  
  466.  
  467. {===================================== L I S T   B O X E S  =======================================    }
  468. {All list box operations pertain to the "current" window.}
  469.  
  470. {Create a new List Box}
  471.     procedure NewListBox (ListBox: TP_LNums;                    {List box number                                }
  472.                                     left, top, right, bottom: Integer;                    {List box co-ordinates (local)                    }
  473.                                     BoxType: SignedByte);                            {Type of responses to mouse clicks, shift-click,    }
  474.                                                                     {    dragging, etc.                                }
  475.  
  476. {Create a new List Box (co-ordinates specified as a 'rect') }
  477.     procedure NewListBoxRect (ListBox: TP_LNums;                {List box number                                }
  478.                                     Bounds: rect;                                        {List box co-ordinates (local)                    }
  479.                                     BoxType: SignedByte);                            {Type of responses to mouse clicks, shift-click,    }
  480.                                                                     {    dragging, etc.                                }
  481.  
  482. {Delete a List Box}
  483.     procedure DeleteListBox (ListBox: TP_LNums);                {List box number                                }
  484.  
  485. {Set a line of text in a List Box}
  486.     procedure SetListBoxText (ListBox: TP_LNums;                {List box number                                }
  487.                                     LineNum: TP_LnNums;                            {Line number                                    }
  488.                                     Text: string);                                    {Text of specified line number                    }
  489.  
  490. {Get a line of text from a List Box}
  491.     procedure GetListBoxText (ListBox: TP_LNums;                {List box number                                }
  492.                                     LineNum: TP_LnNums;                            {Line number                                    }
  493.                                     var Text: Str255);                                {Text of specified line number                    }
  494.  
  495. {Get a List Box's line number whose text is greater than or equal to the specified string}
  496.     function SearchListBox (ListBox: TP_LNums;                    {List box number                                }
  497.                                     Text: string                                        {Text being compared                            }
  498.                                     ): integer;                                            {Line number of text                            }
  499.  
  500. {Select/deselect a specified List Box line}
  501.     procedure SetListBoxLine (ListBox: TP_LNums;                {List box number                                }
  502.                                     LineNum: TP_LnNums;                            {Line number                                    }
  503.                                     setIt: boolean);                                    {Selects the line?                                }
  504.  
  505. {Determine if a specific List Box line is selected}
  506.     function GetListBoxLine (ListBox: TP_LNums;                    {List box number                                }
  507.                                     LineNum: TP_LnNums                            {Line number                                    }
  508.                                     ): boolean;                                        {Is the line selected?                            }
  509.  
  510. {Get the line number of a selected line in a List Box, starting at LineNum and searching down}
  511.     function GetListBoxLines (ListBox: TP_LNums;                    {List box number                                }
  512.                                     LineNum: TP_LnNums                            {Line number                                    }
  513.                                     ): integer;                                            {Next selected line                                }
  514.  
  515. {Insert a blank line into a List Box}
  516.     procedure InsertListBoxLine (ListBox: TP_LNums;                {List box number                                }
  517.                                     LineNum: TP_LnNums);                            {Line number                                    }
  518.  
  519. {Delete a line from a List Box}
  520.     procedure DeleteListBoxLine (ListBox: TP_LNums;                {List box number                                }
  521.                                     LineNum: TP_LnNums);                            {Line number                                    }
  522.  
  523. {Turn a List Box's text drawing on/off}
  524.     procedure DrawListBox (ListBox: TP_LNums;                    {List box number                                }
  525.                                     drawIt: boolean);                                    {Draw the list box's text?                        }
  526.  
  527.  
  528. {========================================= M E N U S ==========================================    }
  529. {Create the "Apple" menu}
  530.     procedure AppleMenu (AboutName: string);                    {Optional "About…" name                        }
  531.  
  532. {Create a menu name, add/change a menu item, or rename an existing menu item}
  533.     procedure Menu (MenuNumber: TP_Mnums;                    {Menu number                                    }
  534.                                     ItemNumber: TP_MInums0;                        {Item number within the menu                    }
  535.                                     EnabledFlag: boolean;                            {Enable the menu?                                }
  536.                                     MenuText: string);                                {Menu title or item name                            }
  537.  
  538. {Insert a menu item}
  539.     procedure InsertMenuItem (MenuNumber: TP_Mnums;            {Menu number                                    }
  540.                                     ItemNumber: TP_MInums;                        {Item number where insertion is to be made        }
  541.                                     EnabledFlag: boolean;                            {Enable the menu?                                }
  542.                                     MenuText: string);                                {Item name                                        }
  543.  
  544. {Remove an entire menu and its associated items, or a menu item}
  545.     procedure RemoveMenu (MenuNumber: TP_Mnums;            {Menu number                                    }
  546.                                     ItemNumber: TP_MInums0);                        {Item number within the menu (0=entire menu)    }
  547.  
  548. {Display the menu bar after making changes through the Menu or RemoveMenu procedure}
  549.     procedure UpdateMenuBar;
  550.  
  551. {Change the name of a menu item}
  552.     procedure RenameItem (MenuNumber: TP_Mnums;                {Menu number                                    }
  553.                                     ItemNumber: TP_MInums;                        {Item number within the menu                    }
  554.                                     MenuText: string);                                {Menu title or item name                            }
  555.  
  556. {Enable/disable a menu or menu item}
  557.     procedure EnableMenu (MenuNumber: TP_Mnums;                {Menu number                                    }
  558.                                     ItemNumber: TP_MInums0;                        {Item number within the menu (or 0)                }
  559.                                     EnabledFlag: boolean);                            {Enable the menu?                                }
  560.  
  561. {Display/remove a menu items check mark}
  562.     procedure CheckMenu (MenuNumber: TP_Mnums;                {Menu number                                    }
  563.                                     ItemNumber: TP_MInums;                        {Item number within the menu                    }
  564.                                     checked: boolean);                                {Place check mark beside the menu item?        }
  565.  
  566. {Mark a menu item with a specified character (√ or •, etc)}
  567.     procedure MenuMark (MenuNumber: TP_Mnums;                {Menu number                                    }
  568.                                     ItemNumber: TP_MInums;                        {Item number within the menu                    }
  569.                                     markChar: char);                                    {Menu item's character                            }
  570.  
  571. {Set the character style for a menu item}
  572.     procedure MenuStyle (MenuNumber: TP_Mnums;                {Menu number                                    }
  573.                                     ItemNumber: TP_MInums;                        {Item number within the menu                    }
  574.                                     theStyle: Style);                                    {Menu item's character style                    }
  575.  
  576. {Highlight a menu in the menu bar, or turn off menu bar highlights}
  577.     procedure MenuHilite (MenuNumber: TP_Mnums0);                {Menu number                                    }
  578.  
  579.  
  580. {======================================= C U R S O R S  ========================================    }
  581. {Cursor Table and Cursor Zone operations pertain to the "current" window.}
  582.  
  583. {Change the cursor shape}
  584.     procedure CursorShape (CursorType: integer);                    {Cursor type                                    }
  585.  
  586. {Reset the cursor to its appropriate shape depending on its location in the active window.}
  587.     procedure ResetCursor;
  588.  
  589. {Create a new Cursor Table}
  590.     procedure NewCursorTable (CursorTable: TP_CtNums;            {Cursor table number                            }
  591.                                     CursorType: integer);                                {Cursor type                                    }
  592.  
  593. {Delete a Cursor Table}
  594.     procedure DeleteCursorTable (CursorTable: TP_CtNums);        {Cursor table number                            }
  595.  
  596. {Add a new Cursor Zone to a Cursor Table, or replace an existing Cursor Zone}
  597.     procedure CursorZone (CursorTable: TP_CtNums;                {Cursor table number                            }
  598.                                     CursorZone: TP_CzNums;                        {Cursor zone number                            }
  599.                                     CursorType: integer;                                {Cursor type                                    }
  600.                                     left, top, right, bottom: Integer);                    {Cursor zone's co-ordinates (local)                }
  601.  
  602. {Add a new Cursor Zone to a Cursor Table, or replace an existing Cursor Zone (co-ordinates specified as a 'rect') }
  603.     procedure CursorZoneRect (CursorTable: TP_CtNums;            {Cursor table number                            }
  604.                                     CursorZone: TP_CzNums;                        {Cursor zone number                            }
  605.                                     CursorType: integer;                                {Cursor type                                    }
  606.                                     ZoneRect: rect);                                    {Cursor zone's co-ordinates (local)                }
  607.  
  608. {Delete a Cursor Zone}
  609.     procedure DeleteCursorZone (CursorTable: TP_CtNums;        {Cursor table number                            }
  610.                                     CursorZone: TP_CzNums);                        {Cursor zone number                            }
  611.  
  612. {Get the co-ordinates of a specified Cursor Zone}
  613.     procedure GetCursorZone (CursorTable: TP_CtNums;            {Cursor table number                            }
  614.                                     CursorZone: TP_CzNums;                        {Cursor zone number                            }
  615.                                     var ZoneRect: rect);                                {Cursor zone's co-ordinates (local)                }
  616.  
  617. {Make the current window use a specified Cursor Table}
  618.     procedure UseCursorTable (CursorTable: TP_CtNums0);        {Cursor table number                            }
  619.  
  620. {Find the cursor zone that contains a specified point}
  621.     function FindCursorZone (thePoint: point                        {Location in window's local co-ordinates            }
  622.                                     ): integer;                                            {Cursor zone number containing the point        }
  623.  
  624. {Enable/disable clicks on push-buttons when the watchCursor is displayed}
  625.     procedure WatchCursorButtons (Allowed: boolean);            {Can push-buttons be clicked when the            }
  626.                                                                     {    watchCursor is displayed?                    }
  627.  
  628.  
  629. {======================================== P O L L I N G =========================================    }
  630. {Tools Plus polling procedure}
  631.     function PollSystem (var UserPoll: TPPollRecord                {Polling record                                    }
  632.                                     ): boolean;                                        {Did an event occurred?                        }
  633.  
  634. {Determine if your application is 'suspended' (i.e. this is not the active application)}
  635.     function ApplicationSuspended: boolean;                        {Is your application suspended?                }
  636.  
  637. {Clear the mouse's current click or drag (i.e. discontinue the process, clear the event}
  638.     procedure ResetMouseClicks;
  639.  
  640.  
  641. {==================================== C O L O R   D R A W I N G ===================================    }
  642. {Determine if the Macintosh has Color QuickDraw}
  643.     function HasColorQuickDraw: boolean;                            {Does the Mac have Color QuickDraw?            }
  644.  
  645. {Determine the number of logical screens (distinct screen depth and color/gray settings)}
  646.     function NumberOfScreens: integer;                            {Number of logical screens available            }
  647.  
  648. {Begin updating the specified logical screen}
  649.     procedure BeginUpdateScreen (TheScreen: integer);            {Logical screen number                            }
  650.  
  651. {End updating the most recent logical screen}
  652.     procedure EndUpdateScreen;
  653.  
  654. {Determine the logical screen's depth}
  655.     function ScreenDepth: integer;                                    {Screen depth in bits                            }
  656.  
  657. {Determine if the logical screen is set to display in color    }
  658.     function ScreenHasColors: boolean;                            {Is the screen set to display in color?            }
  659.  
  660. {Color equivalent to 'PenNormal' routine}
  661.     procedure PenColorNormal;
  662.  
  663. {Color equivalent to 'GetPenState' routine}
  664.     procedure GetColorPenState (var ThePenState: ColorPenState);
  665.  
  666. {Color equivalent to 'SetPenState' routine}
  667.     procedure SetColorPenState (ThePenState: ColorPenState);
  668.  
  669.  
  670. {==================================== M I S C E L L A N E O U S ===================================    }
  671. {Determine the System file version}
  672.     function SystemVersion: extended;                                {System file version (eg: 7.0.1 returned as 7.01)}
  673.  
  674. {Draw an icon (ICON, ICN#, icl8, icl4, and cicn)}
  675.     procedure DrawIcon (theIcon: integer;                            {Icon ID number                                }
  676.                                     left, top: integer;                                    {Icon's top-left corner in window's local co-ord.    }
  677.                                     EnabledFlag, SelectedFlag: boolean);                {Enable the icon?  Select the icon?                }
  678.  
  679. {Draw a standard Macintosh progress thermometer}
  680.     procedure DrawThermometer (DisplayRect: rect;                {Thermometer's co-ordinates (local)                }
  681.                                     Percent: real);                                    {Percent complete (i.e. .5 means 50%)            }
  682.  
  683. {Perform regular processes such as running desk accessories and Edit Fields (60 times per second) }
  684.     procedure SystemTasks;
  685.  
  686. {Display a dynamic Alert Box and return the use's action}
  687.     function AlertBox (theIcon: integer;                                {Icon ID number                                }
  688.                                     AlertText: string;                                {Alert's text                                        }
  689.                                     AlertCode: longint                                {Button setup codes                            }
  690.                                     ): integer;                                            {Button clicked by user                            }
  691.  
  692. {Change a button name for the next use of the dynamic Alert Box}
  693.     procedure AlertButtonName (Button: TP_AltBoxBNums;        {Button number from 1 to 9                        }
  694.                                     Title: string);                                    {Button's title                                    }
  695.  
  696. {Draw "zoom" lines (expanding/collapsing rectangle)}
  697.     procedure ZoomLines (OldRect,                                {Starting rectangle (global co-ordinates)        }
  698.                                     NewRect: Rect;                                    {Ending rectangle (global co-ordinates)            }
  699.                                     Zoom: integer);                                    {Zoom across, in, or out                            }
  700.  
  701. {Wait for a specified duration}
  702.     procedure Wait (ClockTicks: integer);                            {Number of ticks (1/60th sec) to wait            }
  703.  
  704. {Determine the minimum value of 2 numbers}
  705.     function min (Val1, Val2: longint): longint;
  706.  
  707. {Determine the maximum value of 2 numbers}
  708.     function max (Val1, Val2: longint): longint;
  709.  
  710.  
  711.  
  712.  
  713.  
  714. {PRIVATE:    This function obtains the System file's version number as an integer for the SystemVersion function.    }
  715.     function _SYSV: integer;
  716.  
  717.  
  718.  
  719. implementation
  720.  
  721. {The SystemVersion function returns the System File's version as an 'extended' type floating-point number.  This    }
  722. {source code, when compiled, will produce an appropriate 'extended' type floating-point number whose format is        }
  723. {determined by your compiler's settings (ie: Compiled for a math co-processor, 68040, or not)                        }
  724.     function SystemVersion;
  725.     begin
  726.         SystemVersion := _SYSV / 100;                                {Get System Version and convert to an            }
  727.     end;                                                                {    extended type.                                }
  728. end.